package com.kzj.dao;

import com.kzj.domain.Equation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kzj
 * @since 2023-11-15
 */
@Mapper
public interface EquationDao extends BaseMapper<Equation> {
    @Select("select count(*) from equation where exercises_id=#{exerciseId}")
    Integer getCountByExerciseId(Long exerciseId);
    @Select("select count(*) from equation where exercises_id=#{exerciseId} and practice_correctly=1")
    Integer getTureCountByExerciseId(Long id);
    @Select("select count(*) from equation,exercises where equation.exercises_id=exercises.id and exercises.user_phone=#{userPhone} " +
            "and equation.practice_correctly is not null")
    Integer getCountByUserPhone(String userPhone);
    @Select("select count(*) from equation,exercises where equation.exercises_id=exercises.id and exercises.user_phone=#{userPhone} " +
            "and equation.practice_correctly = 1")
    Integer getTureCountByUserPhone(String userPhone);
    @Select("select * from equation,exercises where equation.exercises_id=exercises.id and exercises.user_phone=#{userPhone} " +
            "and equation.practice_correctly = 0")
    List<Equation> getFalseByUserPhone(String userPhone);
//    @Insert("select ")

}
